package scalademo

import scala.collection.immutable

/**
  * Created by 11202 on 2019/3/15.
  */
object Demo1 {


  def main(args: Array[String]): Unit = {

   //第一个参数:数值 第二个参数:函数
   def sum(x:Int,f:Int=>Int)=f(x)

    val ff1=(x:Int)=>{x+2}
    val ff2=(x:Int)=>{x*2}
    println(sum(3,ff1))
    println(sum(2,ff2))

  }
}
